package com.gwnet.rider.controller;

import com.gwnet.common.core.domain.ResponseResult;
import com.gwnet.rider.domain.bo.OrderToRiderBO;
import com.gwnet.rider.service.DispatchService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: WangLiang
 * @date: 2024/8/2 9:11
 */
@RestController
@RequestMapping("/dispatch")
public class DispatchController {

    private final DispatchService dispatchService;

    public DispatchController(DispatchService dispatchService) {
        this.dispatchService = dispatchService;
    }


    /**
     * 系统向骑手进行派单
     * @param orderToRiderBO 订单ID
     * @return 派单结果 true.成功 false。失败
     */
    @PostMapping("/orderToRider")
    public ResponseResult<Boolean> orderToRider(@RequestBody OrderToRiderBO orderToRiderBO){
        Boolean flag = dispatchService.orderToRider(orderToRiderBO.getOrderId());
        return ResponseResult.success(flag);
    }


}
